/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package rps;

import enums.*;

/**
 *
 * @author Gautier
 */
public class RPS {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
    }
    
    public Result play(RPSenum p1, RPSenum p2){
        if(p1==p2) return Result.TIE;
        if(p1==RPSenum.ROCK){
            if(p2==RPSenum.PAPER) return Result.LOST;
            if(p2==RPSenum.SCISSORS) return Result.WIN;
        }
        if(p1==RPSenum.PAPER){
            if(p2==RPSenum.ROCK) return Result.WIN;
            if(p2==RPSenum.SCISSORS) return Result.LOST;
        }
        if(p1==RPSenum.SCISSORS){
            if(p2==RPSenum.PAPER) return Result.WIN;
            if(p2==RPSenum.ROCK) return Result.LOST;
        }
        return Result.LOST;
    }
    
    public Result play(Player p1, Player p2){
        for (int i = 0; i < 10; i++) {
         Result  result = play(p1.getNextMove(), p2.getNextMove());
         if(result == Result.LOST){ p2.score +=1;}
         if(result == Result.WIN){ p1.score +=1;}
         if(result == Result.TIE){ p2.score +=1; p1.score +=1;}
        
    }
        if (p1.score == p2.score){
            return Result.TIE;
        }
        if (p1.score >= 6){
        return Result.WIN;
    }
        
        return Result.LOST;
    
    }
}
